package org.ricks.log;

/**
 * @author chenwei
 * @Title:
 * @Package
 * @Description:
 * @date 2021/1/2917:35
 */
final class DateSegment implements Segment {

    private final TimestampFormatter formatter;

    /**
     * @param format
     *            Pattern for formatting timestamp
     */
    DateSegment(final String format) {
        formatter = RuntimeProvider.createTimestampFormatter(format);
    }

    @Override
    public String getStaticText() {
        return null;
    }

    @Override
    public boolean validateToken(final String token) {
        return formatter.isValid(token);
    }

    @Override
    public String createToken(final String prefix, final Timestamp timestamp) {
        return formatter.format(timestamp);
    }

}

